
import time
import unittest
from selenium import webdriver


from ddt import ddt,file_data

from Page.adduser_Page import adduser_Page
from selenium.webdriver.common.by import By

from Tools.Tools import Tools


@ddt
class AdduserCase(unittest.TestCase):
    @classmethod
    def setUpClass(cls):
        cls.logger = Tools().get_logger("Test.AdduserCase")
    # 测试固件
    def setUp(self):
        self.driver = webdriver.Edge()
        self.driver.maximize_window()
        self.po = adduser_Page(self.driver)
        self.po.login()
        dy_login = self.po.find_element((By.XPATH, '/html/body/div[1]/div[3]/div/div[2]/div/div/p[1]/span')).text
        # 登录成功断言
        self.assertEqual('龙果支付后台', dy_login)
    def tearDown(self):
        time.sleep(5)
        self.driver.quit()

    #添加用户
    @file_data(Tools.resolve_path("Data/add.yaml"))
    def test_01(self,userName,mobile,password):
        try:
            self.po.yonghu()
            time.sleep(3)
            self.po.mess()
            time.sleep(3)
            self.po.add()
            time.sleep(3)
            self.po.ming(userName)
            time.sleep(3)
            self.po.phone(mobile)
            time.sleep(3)
            self.po.denglu(password)
            time.sleep(3)
            self.po.submit()
            dy2=self.po.find_element((By.XPATH, '/html/body/div[1]/div[2]/div[2]/div[2]/div[5]/h2/span')).text
            dy3=self.po.find_element((By.XPATH, '/html/body/div[1]/div[2]/div[2]/div[2]/div[6]/ul/li/div/a')).text

            self.logger.debug(f'断言用户管理入口：{dy2},{dy3}')
            self.logger.info('结果：成功进入用户管理入口')

        except Exception as e:
            self.logger.error(e)

if __name__ == '__main__':
    unittest.main()
